//
//  LWSearchView.swift
//  Swift_Weibo_HLW
//
//  Created by huanglinwang on 16/9/19.
//  Copyright © 2016年 Linwang. All rights reserved.
//

import UIKit

class LWSearchView: UIView {

    @IBOutlet weak var searchTextField: UITextField!
    @IBOutlet weak var searchBtn: UIButton!

    @IBOutlet weak var searchTextFieldRightConstraint: NSLayoutConstraint!

    @IBAction func clickSearchButton(_ sender: AnyObject) {
        
        searchTextField.resignFirstResponder()
        
        searchTextFieldRightConstraint.constant = 0
        
        //延迟动画
        UIView.animate(withDuration: 0.3) {
            self.layoutIfNeeded()
        }
        
    }
     @IBAction func editingBegin(_ sender: AnyObject) {
        searchTextFieldRightConstraint.constant = searchBtn.width
        //延迟动画
        UIView.animate(withDuration: 0.3) {
            self.layoutIfNeeded()
        }
     }
 
    
    //类方法创建对象
    class func searchView()-> LWSearchView{
        return UINib(nibName: "LWSearchView", bundle: nil).instantiate(withOwner: nil, options: nil).last! as! LWSearchView
    }
    
    override func awakeFromNib() {
//        searchTextField.layer.borderColor = UIColor.orange.cgColor
//        searchTextField.layer.borderWidth = 2
//        searchTextField.layer.cornerRadius = 5
//        searchTextField.layer.masksToBounds = true
    }
    
}
